package com.xinxin.base.enums;

import com.xinxin.base.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum CountryCodeEnum {

    CHINA(86, new String[]{"中国大陆", "中國大陸", "Mainland China", "", "", "", "", ""}),
    HONG_KONG(852, new String[]{"中国香港", "中國香港", "HongKong China", "", "", "", "", ""}),
    MACAO(853, new String[]{"中国澳门", "中國澳門", "Macao China", "", "", "", "", ""}),
    TAIWAN(886, new String[]{"中国台湾", "中國台灣", "Taiwan China", "", "", "", "", ""}),
    AMERICA(1, new String[]{"美国", "美國", "America", "", "", "", "", ""}),
    MALAYSIA(60, new String[]{"马来西亚", "馬來西亞", "Malaysia", "", "", "", "", ""}),
    INDONESIA(62, new String[]{"印度尼西亚", "印度尼西亞", "Indonesia", "", "", "", "", ""}),
    PHILIPPINES(63, new String[]{"菲律宾", "菲律宾", "Philippines", "", "", "", "", ""}),
    SINGAPORE(65, new String[]{"新加坡", "新加坡", "Singapore", "", "", "", "", ""}),
    THAILAND(66, new String[]{"泰国", "泰國", "Thailand", "", "", "", "", ""}),
    JAPAN(81, new String[]{"日本", "日本", "Japan", "", "", "", "", ""}),
    KOREA(82, new String[]{"韩国", "韓國", "Korea", "", "", "", "", ""}),
    VIETNAM(84, new String[]{"越南", "越南", "Vietnam", "", "", "", "", ""}),
    BRUNEI(673, new String[]{"文莱", "文莱", "Brunei", "", "", "", "", ""}),
    NEPAL(977, new String[]{"尼泊尔", "尼泊尔", "Nepal", "", "", "", "", ""}),
    ;

    public static final int SIMPLE_CHINESE = 0; // 简体中文
    public static final int TRADITIONAL_CHINESE = 1; // 繁体中文
    public static final int ENGLISH = 2; // 英语
    public static final int THAI = 3; // 泰语
    public static final int KOREAN = 4; // 韩语
    public static final int VIETNAMESE = 5; // 越南语
    public static final int JAPANESE = 6; // 日语
    public static final int INDONESIAN = 7; // 印尼语

    private int code;
    private String[] names;

    public String getName(int language) {
        if (language < 0 || language > names.length - 1) {
            throw new BusinessException(HttpStatus.BAD_REQUEST.value(), "不支持的语言");
        }

        return names[language];
    }
}
